/**
 * Copyright &copy; 2012-2016 <a href="https://www.kaaction.com">KAA</a> All rights reserved.
 */
package com.kaaction.modules.sys.web.api;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.kaaction.common.web.BaseController;
import com.kaaction.common.utils.QiniuUtils;

/**
 * 客户Controller
 * @author zengbiao
 * @version 2017-04-13
 */
@Controller
@RequestMapping(value = "/api/v1/qiniu")
public class QiniuApiController extends BaseController {

	@RequestMapping(value = {"token"})
	public void token(HttpServletRequest request, HttpServletResponse response) throws IOException {
		
		response.setHeader("Access-Control-Allow-Origin", "*");
		PrintWriter pw = response.getWriter();
		pw.write(QiniuUtils.getToken());
		pw.flush();
		pw.close();
	}
	
	@RequestMapping(value = {"host"})
	public void host(HttpServletRequest request, HttpServletResponse response) throws IOException {
		
		response.setHeader("Access-Control-Allow-Origin", "*");
		PrintWriter pw = response.getWriter();
		pw.write(QiniuUtils.getCloudDomain());
		pw.flush();
		pw.close();
	} 
	
	

}